/**
 * DbmsClient.java create at Aug 30, 2011
 * author: weapon
 */
package dbms.server;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

import dbms.Constants;

/**
 * @author weapon
 */
public class DbmsClient {
	public static void main(String args[]) {
		try {
			Socket socket = new Socket("127.0.0.1", Constants.DBMS_PORT);
			BufferedReader sin = new BufferedReader(new InputStreamReader(
					System.in));
			PrintWriter os = new PrintWriter(socket.getOutputStream());
			BufferedReader is = new BufferedReader(new InputStreamReader(
					socket.getInputStream()));
			
			String readline;
			System.out.print("sjkV5 > ");
			readline = sin.readLine();
			while (!readline.equals("exit")) {
				os.println(readline);
				os.flush();
				
				
				String[] responseLine = is.readLine().split("#");
				for(int i = 0; i < responseLine.length; i++){
					System.out.println(responseLine[i]);
				}

				System.out.print("sjkV5 > ");
				readline = sin.readLine();
			}
			os.close(); 
			is.close(); 
			socket.close(); 
		} catch (Exception e) {
			System.out.println("Error" + e);
		}
	}
}
